let map = new Map();

map.set("1", "str1");
map.set(1, 'num1');
map.set(true, 'bool1');

alert(map.get(1));
alert(map.get('1'));
alert(map.size);


// 使用对象作为键
let john = {name: 'John'};
let visitsCountMap = new Map();

visitsCountMap.set(john, 123);
alert(visitsCountMap.get(john));

// map迭代
// 使用带有键值对的数组，来初始化map
let recipeMap = new Map([
    ['cucumber', 500],
    ['tomatoes', 350],
    ['onion', 50],
]);


for (let vege of recipeMap.keys()) {
    alert(vege);
}


for (let amount of recipeMap.values()) {
    alert(amount);
}

for (let entry of recipeMap) {
    alert(entry);
}